from Score import func_score
tol=0.00001
# S特征集，F特征，数据集
def func_sbf(S,F,df_rating):
    Score = func_score(S,df_rating)
    i=0
    while i<len(F):
        S.remove(F[i])
        S_new=S
        print("s_new",S_new)
        S=S_new+[F[i]]
        print("S",S)
        if len(S_new)==0:
            S_op=S
            i=len(F)+1
            print("S_op1")
            print(S_op)

        else:
            # print(S_new)

            # Score_new= func_score(S_new,df_rating)
            Score_new= func_score(S_new,df_rating)
            print("旧", Score)
            print("新",Score_new)

            if i== len(F)-1 and Score_new<Score +tol:
                print("最终准确率",Score)
                S_op=S
                i=len(F)+1
                print("S_op2")
                print(S_op)

            else:
                i+=1
                if(Score_new>=Score+tol):
                    Score=Score_new
                    F.pop(i - 1)
                    S = S_new
                    print("ccc")
                    i = 0
